package fatherday;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;
import java.util.Scanner;

public class FatherDay {
    public static void main(String[] args) {
        /*5、从控制台输入年份，计算父亲节？(提示：母亲节为每年的5月第二个星期日)*/
        Scanner input = new Scanner(System.in);
        System.out.printf("请输入任意一个年份：");
        int year = input.nextInt();
        LocalDate date = LocalDate.of(year, 6, 1);
        for (int i = 1; i < 8; i++) {//从一号到七号，找出第一个星期日
            date = LocalDate.of(year, 6, i);//如果找不到重置日期
            if (date.getDayOfWeek()== DayOfWeek.SUNDAY) {//判断是否是周日
                date = LocalDate.of(year, 6, i + 14);//找到后重置日期至两个星期后
                break;
            }
        }
        DateTimeFormatter dayFormater = DateTimeFormatter.ofPattern("M月dd日");
        String dateStr = date.format(dayFormater);
        System.out.println(dateStr);//打印字符串
    }
}
